/*
 * @Author: huangjin999
 * @Date: 2024-02-19 10:12:12
 * @LastEditors: huangjin999
 * @LastEditTime: 2024-11-08 10:39:59
 */
import "./assets/main.css";

import { createApp } from "vue";
import { createPinia } from "pinia";

// vxe

import VxeTable from "vxe-table";
import "vxe-table/lib/style.css";
// ...

import VxeUI from "vxe-pc-ui";
import "vxe-pc-ui/lib/style.css";

import App from "./App.vue";
import router from "./router";
import './router/permission'

// // 模拟登录成功后获取的用户角色信息
// const userRoles = ["admin"];

// // 在创建 Vue 应用之前调用 setupRouter 方法，动态生成路由
// setupRouter(userRoles);
// element plus
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

// 暗黑主题
import 'element-plus/theme-chalk/dark/css-vars.css'


//引入模板的全局的样式
import "@/styles/index.scss";

//引入echarts
import * as echarts from "echarts";
//
// import "./permission";
// mock
import './mock/index.js'

// three.js
// import * as THREE from "three";

// pinia持久化
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';

const app = createApp(App);
//全局挂载echarts
app.config.globalProperties.$echarts = echarts;
//全局挂载icon图标
app.config.globalProperties.$icon = ElementPlusIconsVue

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);



app.use(pinia);
app.use(router);
app.use(ElementPlus);
app.use(VxeUI);
app.use(VxeTable);


// import { usePermissionStore } from '@/stores/permissionStore.js';
// import { getToken } from '@/utils/auth';

// const initializePermissions = async () => {
//   const permissionStore = usePermissionStore();
//   const token = getToken();
  
//   if (token) {
//     const permissions = JSON.parse(localStorage.getItem('roles') || '[]');
//     if (permissions.length > 0) {
//       await permissionStore.generateRoutes(permissions);
//     }
//   }
// };

// initializePermissions().then(() => {
  app.mount('#app');
// });
